'use strict';

var mysql = require('mysql');
var connection = mysql.createConnection({
    host: 'localhost',
    user: 'root',
    password: 'root',
    database: 'equipment'
});


//查询
//执行数据库操作并执行回调，有err则抛出异常，控制台输出结果

connection.query('select * from e_instrument', function (error, results, fields) {
    if (error) {
        console.log('出错了！');
    }
    console.log('查询结果为: ', results);
});

//关闭连接
connection.end();